<!DOCTYPE html>
<body>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>邻里社</title>

	<link rel="stylesheet" href="css/dongtai.css" />
	<link rel="stylesheet" href="css/homepage.css" />
	<link rel="stylesheet" href="css/footer.css" />
	<link href="css/bootstrap.css" rel="stylesheet">
	<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="body">
<div class="container-fluid header" style="">
	<div class="row">
		<div class="col-xs-12 nav2" style="">
			<div class="col-xs-2">
				<p class="yh" style="margin-left: -10px;"><img src="img/定位.png" height="22px"/></p>
			</div>
			<div class="col-xs-8 titile">
				<p style="text-align: center;font-size: 24px;font-weight: bolder;">社区动态</p>
			</div>
			<div class="col-xs-1">
				<a href="publish"><p style="margin-left: -22px;" class="yh"><img src="img/发.png" width="24px"/></p></a>
			</div>
			<div class="col-xs-1">
				<p style="margin-left: -12px;" class="yh"><img src="img/信息.png" width="24px"/></p>
			</div>
		</div>
	</div>
</div>

<div style="margin-bottom: 70px">
<#list commList as comms>
<div class="dongtai" style="padding:10px 20px;margin-top:12px;background: white;">
	<p class="mouren"><span><img src="img/${comms.userHead}" width="40px" style="border-radius: 50%;"></span>&nbsp;&nbsp;${comms.userName}<span><img src="img/jiankuohao.svg" width="20px"/></span></p>
	<p style="color: #8C8A8D;">${comms.commContent}</p>
	<p><img src="img/${comms.commImg}" style="max-width:350px;" ></p>
	<p class="shijian"><span class="time">${comms.commTime}</span></p>
	<ul class="xiamian">
		<li><a href=""></a> <img src="img/fenxiang.png" width="20px"/>&nbsp;&nbsp;分享</a></li>
		<li><a href="dongtaiTwo?commId=${comms.commId}" class="pingl"><img src="img/评论.png" width="20px"/>&nbsp;&nbsp;评论</a></li>
		<li><a href="" class="pingl"><img src="img/xin.png" width="20px"/>&nbsp;&nbsp;赞</a></li>
	</ul>
</div>
</#list>
</div>

<!-- 底部-->
<div class="foot">
	<div class="foott">
		<ul>
			<li>
				<a href="homepage"><p><img src="img/首页.png"></p><p>首页</p></a>
			</li>
			<li>
				<a href="doserve"><p><img src="img/服务图.png"></p><p>服务</p></a>
			</li>
			<li>

				<a href="dong"><p><img src="img/邻星图.png"></p><p>邻里社</p></a>

			</li>
			<li>
				<a href="myinfo"><p><img src="img/我.png"></p><p>我的</p></a>
			</li>
		</ul>
	</div>
</div>


<script type="text/javascript" src="js/jquery-3.2.1.js" ></script>
<script>
	function setTime(time,timeSelector){
		var currentTime = Date.parse(new Date());
		var dateTime = time;//后台传递来的时间
		var ts = timeSelector;//选择器
		var d_day = Date.parse(new Date(dateTime));
		var day = Math.abs(parseInt((d_day - currentTime)/1000/3600/24));//计算日期
		var hour = Math.abs(parseInt((d_day - currentTime)/1000/3600));//计算小时
		var minutes = Math.abs(parseInt((d_day - currentTime)/1000/60));//计算分钟
		var seconds = Math.abs(parseInt((d_day - currentTime)/1000));//计算秒
		console.log(day);
		if(day >= 2){
			ts.text(parseInt(day)+"天前").toString();
		}else if(day > 0 && day < 2){
			ts.text("昨天").toString();
		}else if(hour > 0 && hour < 24){
			ts.text(parseInt(hour)+"小时前").toString();
		}else if(minutes > 0 && minutes < 60){
			ts.text(parseInt(minutes)+"分钟前").toString();
		}else if(seconds > 0 && seconds < 60){
			ts.text(parseInt(seconds)+"秒前").toString();
		}
	}
	//列表里面调用方法，传递两个参数 数据库时间和选择器
	$(".dongtai").each(function(){
		var t_time = $(this).find(".time").text();
		var timeSelector = $(this).find(".time");
		setTime(t_time,timeSelector);
	})
</script>
</body>

</html>
